<?php
	$row = $result[0];
	    echo form_open_multipart("admin/news/update/$catID/".$row['news_id']); ?>	<!-- start title -->
		<div class="title corners_top" style="float:left;width:600px;">
        	<h6 style="color:#900;" id="forms">
        		CẬp nhật tin tức <span style="color:#F00"><?php echo $namecat?></span>
        	</h6>
        </div><!-- end title -->
<div class="proccess_bar">
  <ul class="menu_bar">
    <li>
		<?php $data = array('name' => 'update', 'value' => ' ','class'=>'delete-1', 'id' => 'save');
	 	echo form_submit($data);?> <!--<a href="#" ><span class="save-1"> </span>Save</a> -->
     	Lưu
     </li>
     <li> 
		<?php 
			 $data = array('name' => 'close', 'value' => ' ','class'=>'delete-1', 'id' => 'cancel');
			 echo form_submit($data);
		?>Hủy<!--<a href="#" ><span class="cancel-1"></span>Cancel</a>-->
     </li>
  </ul>
</div>
<div class="content">
   <div class="form" >
   <?php 
	   if(isset($missing) && is_array($missing) )
	   {
			echo ' <div><a href="javascript:();" title="Succes box" class="box error corners"><span class="close">&nbsp;</span>';
			foreach($missing as $item)
			{
				echo $item."<br />";
			}
			echo "</a></div>";
	   }
	   $code = "img";
	   $label =$this->lang->line('image');
   ?>
   
     <p>
     	<h6 class="t_float" style="clear:left"><?php echo 	$label =$this->lang->line('image'); ?></h6>
     	<div class="images">
			<input type="text" id="fileName" class="file_input_textbox corners_left" readonly="readonly" />
 			<div class="file_input_div">
				<input type="button" value="" class="file_input_button" />
				<input type="file" name="img" id="img" class="file_input_hidden" onchange="javascript: document.getElementById('fileName').value = this.value" />
			</div>
		</div>
         <?php if($row['news_image'] != "") {?> 
         		<img width="120" src="<?php echo base_url()?>upload/news/<?php echo $row['news_image']?>" />   
                <span> 
                	<a href="<?php echo base_url()."index.php/admin/news/del_image/$catID/".$row['news_id'];?>" style="color:#900;font-weight:bold" >Xóa Hinh </a>
                </span>
         
          <?php }?>
	</p>     

     <p>
     	<h6 class="t_float" style="clear:left">Loại Phòng:</h6>
        <?php if(!empty($type)){ ?>
        <div class="images">
			<select name="room_type">
            	<?php 
						foreach ($type as $data)
						{
							
				?>
                			<option <?php if($data['type_id'] == $row['type_id']) echo 'selected="selected"'; ?>  value="<?php echo $data['type_id']?>"><?php echo $data['type_name']?></option>
				<?php			
						}
				?>
            </select>
         </div>
         <?php } else {?>
          <div class="images" style="padding-top:15px;">
         		<a style="margin-top:10px;font-weight:bold" href="<?php echo base_url()?>/index.php/admin/news_type/index/<?php echo $row['type_ids'] ?>">Vui lòng click vào đây để thêm loại phòng trước khi thêm tin</a>          
			</div>
				<?php }?>
			
	</p>  
    <p>
    	<h6>Mã tin: </h6>
    	<?php 
			echo '<div class="inner">';
	$code = "code";
	$value = $row['news_code'];
	$label ="Mã tin".' <font color="red" style="font-weight:bold">(*)</font>';
	$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code,'value'=>$value);
	echo '<div  class="t_float2">',($label),'</div>';
	if (! empty($missing) && array_key_exists($code, $missing))

		 echo form_input($data, set_value($code)),'<span class="info_error">error</span>';

	else
	  echo form_input($data, set_value($code));
	
	
	echo '</div>';
		?>
    </p>
	<p>
	<h6><?php echo $this->lang->line('news_title'); ?></h6>
        
<?php
	//title  vi
	echo '<div class="inner">';
	$code = "title_vi";
	$value = html_entity_decode($row['news_name'],ENT_QUOTES,'UTF-8');
	$label ="Vietnamese".' <font color="red" style="font-weight:bold">(*)</font>';
	$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code,'value'=>$value);
	echo '<div  class="t_float2">',($label),'</div>';
	if (! empty($missing) && array_key_exists($code, $missing))

		 echo form_input($data, set_value($code)),'<span class="info_error">error</span>';

	else
	  echo form_input($data, set_value($code));
	
	
	echo '</div>';

	if($num_lang > 1)
	{
	//title en

	echo '<div class="inner">';
	$code = "title_en";
	$value = html_entity_decode($row['news_name_en'],ENT_QUOTES,'UTF-8');
	$label ="English".' <font color="red" style="font-weight:bold">(*)</font>';

	
echo '<div  class="t_float2">',($label),'</div>';		

	$data = array('name' =>$code,'class'=>'large_input corners','value'=>$value);

		if (! empty($missing) && array_key_exists($code, $missing))

		 echo form_input($data, set_value($code)),'<span class="info_error">error</span>';

	else
	  echo form_input($data, set_value($code));

	echo '</div>';
	}
?>
 
</p>

<p>
	<h6>Giá:</h6>
        
<?php
	
	echo '<div class="inner">';
	$code = "price_vnd";
	$value = $row['news_price_vnd'];
	$label ="VNĐ".' <font color="red" style="font-weight:bold">(*)</font>';
	$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code,'value'=>$value);
	echo '<div  class="t_float2">',($label),'</div>';
	if (! empty($missing) && array_key_exists($code, $missing))

		 echo form_input($data, set_value($code)),'<span class="info_error">error</span>';

	else
	  echo form_input($data, set_value($code));
	echo '</div>';
	
	echo '<div class="inner">';
	$code = "price_sjc";
	$value = $row['news_price_sjc'];
	$label ="SJC".' <font color="red" style="font-weight:bold">(*)</font>';
	$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code,'value'=>$value);
	echo '<div  class="t_float2">',($label),'</div>';
	if (! empty($missing) && array_key_exists($code, $missing))

		 echo form_input($data, set_value($code)),'<span class="info_error">error</span>';

	else
	  echo form_input($data, set_value($code));
	echo '</div>';
	
	echo '<div class="inner">';
	$code = "price_usd";
	$value = $row['news_price_usd'];
	$label ="USD".' <font color="red" style="font-weight:bold">(*)</font>';
	$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code,'value'=>$value);
	echo '<div  class="t_float2">',($label),'</div>';
	if (! empty($missing) && array_key_exists($code, $missing))

		 echo form_input($data, set_value($code)),'<span class="info_error">error</span>';

	else
	  echo form_input($data, set_value($code));
	echo '</div>';
	
?>
<div class="inner">
 <div  class="t_float2"> Loại giá: </div>
     <select name="news_pricetype" >
     		<option <?php if($row['news_pricetype'] == 0) echo 'selected="selected"'?>  value="0">  m2 </option>
            <option <?php if($row['news_pricetype'] == 1) echo 'selected="selected"'?> value="1">  Theo tháng</option>
     </select>
     </div> 
</p>
<p>
	<h6>Các tính nắng dùng tim kiếm tin:</h6>
     <div class="inner">
         <div  class="t_float2"> Nhu cầu: </div>
         <select name="news_need" class="large_input corners">
                <option <?php if($row['news_need'] == 0) echo 'selected="selected"'?>  value="0"> Cần bán </option>
                <option <?php if($row['news_need'] == 1) echo 'selected="selected"'?>  value="1"> Cho thuê</option>
         </select>
     </div>  
     
     <div class="inner">
         <div  class="t_float2"> Loại BDS: </div>
         <select name="news_type" class="large_input corners">
                <option <?php if($row['news_type'] == 0) echo 'selected="selected"'?>  value="0"> Căn hộ thường </option>
                <option <?php if($row['news_type'] == 1) echo 'selected="selected"'?> value="1"> Penthouse</option>
                <option <?php if($row['news_type'] == 2) echo 'selected="selected"'?> value="2"> Duplex</option>
                <option <?php if($row['news_type'] == 3) echo 'selected="selected"'?> value="3"> Villa</option>
         </select>
     </div> 
     
     <div class="inner">
         <div  class="t_float2"> Nội thất: </div>
         <select name="news_furniture" class="large_input corners">
                <option <?php if($row['news_furniture'] == 0) echo 'selected="selected"'?> value="0">  Nhà trống </option>
                <option <?php if($row['news_furniture'] == 1) echo 'selected="selected"'?> value="1">  Nội thất cơ bản</option>
                <option <?php if($row['news_furniture'] == 2) echo 'selected="selected"'?> value="2">  Nội thất đầy đủ</option>
                <option <?php if($row['news_furniture'] == 3) echo 'selected="selected"'?> value="3">  Nội thất cao cấp</option>
         </select>
     </div>  
     <div class="inner">
     	<div  class="t_float2"> Số phòng ngủ: </div>
		<input type="text" value="<?php echo $row['news_num_room']?>" name="num_room" class="large_input corners" />
    </div> 
   <div class="inner">
     	<div  class="t_float2"> số lầu: </div>
		<input type="text" value="<?php echo $row['news_num_floor']?>"  name="num_floor" class="large_input corners" />
    </div>  
   <div class="inner">
     	<div  class="t_float2"> Diện tích </div>
		<input type="text" value="<?php echo $row['news_area']?>" name="news_area" class="large_input corners" />
    </div>   
</p>


<h6 class="t_float" > Trạng thái </h6>

<div class="float radio">
<input  type="radio" <?php if($row['news_status'] == 1) echo 'checked="checked"'?> name="status" id="status" value="1" checked="checked" />Hiện

<input  type="radio" <?php if($row['news_status'] == 0) echo 'checked="checked"'?> name="status" id="status" value="0 "/> ẩn
</div>

<p>
<h6 class="t_float" style="width:200px;" > Giới thiệu ngắn </h6>
	<?php 
	
	$code = "short";
	$value = html_entity_decode($row['news_short'],ENT_QUOTES,'UTF-8');
	$label ="Vietnamese";
	echo '<div class="t_float2"> '.$label.'</div>';
	$data = array('name' =>$code,'id' => $code,'class'=>'large_input corners','value' =>$value,"style"=>"width:95% !important;height:200px !important");
	echo form_textarea($data);	
	?>
    <?php 
	$code = "short_en";
	$value = html_entity_decode($row['news_short_en'],ENT_QUOTES,'UTF-8');
	$label ="English";
	echo '<div class="t_float2"> '.$label.'</div>';
	$data = array('name' =>$code,'id' => $code,'class'=>'large_input corners','value' =>$value,"style"=>"width:95% !important;height:200px !important");
	echo form_textarea($data);	
	?>
</p>


<p>
<h6>Chi tiết</h6> 
<?php

			//direction vietname
	$code = "direction_vi";
	$value = html_entity_decode($row['news_detail'],ENT_QUOTES,'UTF-8');
	$label ="Vietnamese";
	echo '<p>';
		echo '<div class="t_float2"> '.$label.'</div>';
		echo '<div class="float">';
		$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code, 'value' =>$value);
		echo '<div class="textarea"> '.form_textarea($data).'</div>';
		echo '</div>';
	echo '</p>';	
	
?>
<?php

			//direction vietname
	$code = "direction_en";
	$value = html_entity_decode($row['news_detail_en'],ENT_QUOTES,'UTF-8');
	$label ="English";
	echo '<p>';
		echo '<div class="t_float2"> '.$label.'</div>';
		echo '<div class="float">';
		$data = array('name' =>$code,'class'=>'large_input corners' ,'id' => $code, 'value' =>$value);
		echo '<div class="textarea"> '.form_textarea($data).'</div>';
		echo '</div>';
	echo '</p>';	
	
?>
</p>

<?php




	echo form_close(); //FORM END

	
	
	?> 
     </div>
     </div>   
     

<script type="text/javascript">

// This is a check for the CKEditor class. If not defined, the paths must be checked.
if ( typeof CKEDITOR == 'undefined' )
{
	document.write(
		'<strong><span style="color: #ff0000">Error</span>: CKEditor not found</strong>.' +
		'This sample assumes that CKEditor (not included with CKFinder) is installed in' +
		'the "/ckeditor/" path. If you have it installed in a different place, just edit' +
		'this file, changing the wrong paths in the &lt;head&gt; (line 5) and the "BasePath"' +
		'value (line 32).' ) ;
}
else
{

	var editor =		CKEDITOR.replace("direction_vi");
	<?php   echo 'var editor2 = CKEDITOR.replace("direction_en");'?>

	//editor.setData( '<p>Just click the <b>Image</b> or <b>Link</b> button, and then <b>&quot;Browse Server&quot;</b>.</p>' );
	//editor2.setData( '<p>Just click the <b>Image</b> or <b>Link</b> button, and then <b>&quot;Browse Server&quot;</b>.</p>' );
	//editor3.setData( '<p>Just click the <b>Image</b> or <b>Link</b> button, and then <b>&quot;Browse Server&quot;</b>.</p>' );
	// Just call CKFinder.SetupCKEditor and pass the CKEditor instance as the first argument.
	// The second parameter (optional), is the path for the CKFinder installation (default = "/ckfinder/").
	CKFinder.setupCKEditor( editor,'<?php echo base_url(); ?>public/scripts/admin/ckfinder') ;  //'../../../../../public/scripts/admin/ckfinder') ;
<?php   echo "CKFinder.setupCKEditor( editor, '".base_url()."public/scripts/admin/ckfinder') ;"?>
	// It is also possible to pass an object with selected CKFinder properties as a second argument.
	// CKFinder.SetupCKEditor( editor, { BasePath : '../../', RememberLastFolder : false } ) ;
}

		</script>